<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
</head>
<body>
    <img id="img" src="../img/hz_1.jpg">
</body>
</html>
<script>
    /**
     * 页面加载显示html中的图片，所以第一张一定是body中所指定的
     * */
    var number=1;
    function f() {
        number++;
        if (number>3){
            number=1;
        }
        var elementById = document.getElementById("img");
        elementById.src="../img/hz_"+number+".jpg";

    }
    setInterval(f,3000);
</script>